package pms.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import pms.dao.TheaterDao;
import pms.om.Theater;



/** 
 * Controller to generate the Home Page basics to be rendered by a view. 
 * It extends the convenience class AbstractController that encapsulates most 
 * of the drudgery involved in handling HTTP requests. 
 * @author KRS DEV Team (krsdevteam@PMSWIbb2011SS.de)
 */
public class ShowTheater extends AbstractController {
	
    private static Log log = LogFactory.getLog(AlleTheater.class);
	private TheaterDao theaterDao;

	public void setTheaterDao(TheaterDao theaterDao) {
		this.theaterDao = theaterDao;
	}
	
	public TheaterDao getTheaterDao() {
		return theaterDao;
	}
	
	protected ModelAndView handleRequestInternal(
			HttpServletRequest httpServletRequest,
			HttpServletResponse httpServletResponse) throws Exception {
		
		httpServletRequest.setCharacterEncoding("UTF-8");
		int id = Integer.parseInt(httpServletRequest.getParameter("theaterId"));
		
		ModelAndView mv = new ModelAndView();
		mv.addObject("privileged", httpServletRequest.isUserInRole("admin"));
		mv.addObject("title", "Theaterinfo");
		mv.addObject("message", "Zus�tzliche Informationen zum Theater der Veranstaltung.");
		mv.addObject("theater", theaterDao.findById(id));
		mv.setViewName("show-theater");
		return mv;
		//return super.handleRequestInternal(httpServletRequest, httpServletResponse);
	}

}
